package com.dk.mybatisplus;

import com.dk.mybatisplus.pojo.User;
import com.dk.mybatisplus.service.UserService;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.ArrayList;
import java.util.List;

@SpringBootTest
public class MybatisPlusService {
    @Autowired
    private UserService userService;

    @Test
    void testGetUser() {
        long count = userService.count();//查询所有数据总记录数
        //SELECT COUNT( * ) FROM user
        System.out.println(count);
    }

    @Test
    void testInsertMore() {
        List<User> users = new ArrayList<>();
        for (int i = 0; i < 15; i++) {
            User user  = new User();
            user.setName("lisi");
            user.setEmail("12"+i+"@qq.com");
            user.setAge(100);
            users.add(user);
        }
        boolean result = userService.saveBatch(users);
        System.out.println(result?"成功":"不成功");
    }
}
